/*
 *    Copyright (c) 2018-2025, bfcloud All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: bfcloud
 */
import {getDetails} from '@/api/admin/user'


var validateUsername = (rule, value, callback) => {
  getDetails(value).then(response => {
    if (window.boxType === 'edit') callback()
    const result = response.data.data
    if (result !== null) {
      callback(new Error('用户名已经存在'))
    } else {
      callback()
    }
  })
}
var validatePassword=(rule, value, callback)=>{
  var reg=/^[A-Z](?=.*[0-9]+)(?=.*[a-z]+)(?=.*[~!@#$%^&*_.]+).{7,17}|^[a-z](?=.*[0-9]+)(?=.*[A-Z]+)(?=.*[~!@#$%^&*_.]+).{7,17}/;
  if(value){
    if(!reg.test(value)){
      callback("密码必须由字母开头且包含字母大小写数字特殊符号组成的8-18位字符!")
    }else{
      callback()
    }
  }else{
    callback()
  }

}
export const tableOption = {
  border: true,
  index: true,
  indexLabel: '#',
  stripe: true,
  menuAlign: 'center',
  searchMenuSpan: 6,
  editBtn: false,
  delBtn: false,
  labelWidth: 120,
  menuWidth:180,
  top:0,
  align: 'center',
  addBtn: false,
  column: [{
    fixed: true,
    label: 'id',
    prop: 'userId',
    span: 24,
    hide: true,
    editDisabled: true,
    addDisplay: false
  }, {
    fixed: true,
    label: '用户',
    prop: 'username',
    editDisabled: true,
    overHidden: true,
    slot: true,
    search: true,
    span: 12,
    rules: [{
      required: true,
      message: '请输入用户名'
    },
      {
        min: 3,
        max: 20,
        message: '长度在 3 到 20 个字符',
        trigger: 'blur'
      },
      {validator: validateUsername, trigger: 'blur'}
    ]
  }, {
    label: '密码',
    prop: 'password',
    type: 'password',
    value: '',
    hide: true,
    span: 12,
    rules: [{
      min: 8,
      max: 18,
      message: '长度在 8 到 18 个字符',
      trigger: 'blur'
    },
    {validator: validatePassword, trigger: 'blur'}
  ]
  }, {
    label: '姓名',
    overHidden: true,
    prop: 'ryName',
    value: '',
    span: 12,
    rules: [{
      required: true,
      message: '请输入用户名'
    }, {
      min: 2,
      max: 20,
      message: '长度在 2 到 20 个字符',
      trigger: 'blur'
    }]
  }, {
    label: '职务',
    prop: 'ryZw',
    slot: true,
    width:120,
    value: '',
    overHidden: true,
    span: 12
  },{
    label: '原任职务',
    width:120,
    prop: 'yrZw',
    // slot: true,
    // value: '',
    overHidden: true,
    span: 12
  },{
    label: '选拔方式',
    width:120,
    prop: 'xbFs',
    // slot: true,
    // value: '',
    overHidden: true,
    span: 12
  },{
    label: '出生年月',
    width:120,
    prop: 'rySr',
    type: 'date',
    format: 'yyyy-MM-dd',
    valueFormat: 'yyyy-MM-dd',
    // slot: true,
    // value: '',
    overHidden: true,
    span: 12
  },
    {
      label: '人员任职时间',
      width:120,
      prop: 'ryZjsj',
      type: 'date',
      format: 'yyyy-MM',
      valueFormat: 'yyyy-MM',
      // slot: true,
      // value: '',
      span: 12
    },{
    label: '性别',
    prop: 'ryXb',
    value: '',
    span: 12,
    type:"select",
    dicData:[
      {label: '男',value:'男'},
      {label: '女',value:'女'}
    ],
    dataType: "string",
    hide: true,
  }, {
    label: '手机',
    prop: 'phone',
    value: '',
    span: 12,
    hide: true,
    rules: [{
      min: 11,
      max: 11,
      message: '长度在 11 个字符',
      trigger: 'blur'
    }]
  },{
      label: '文化程度',
      prop: 'ryWhcd',
      value: '',
      span: 24,
      hide: true,
    },
    // {
    //   label: '职级名称',
    //   prop: 'ryZjmc',
    //   type:"select",
    //   value: '',
    //   dataType: "string",
    //   span: 24,
    //   hide: true,
    // },
    {
    label: '职级名称',
    prop: 'ryZjbm',
    formslot: true,
   // searchslot:true,
   //  search: true,
    value: '',
    span: 24,
    hide: true
  },
    //  {
  //   label: '身份',
  //   prop: 'ryCpsf',
  //   value: '',
  //   span: 12,
  //   hide: true
  // },
    {
    label: '部门',
    prop: 'deptId',
    formslot: true,
    slot: true,
    span: 24,
    hide: true,
    dataType: "number",
    rules: [{
      required: true,
      message: '请选择部门',
      trigger: 'change'
    }]
  },
  {
    label: '单位',
    prop: 'orgaId',
    formslot: true,
    slot: true,
    span: 24,
    hide: true,
    dataType: "number",
    rules: [{
      required: true,
      message: '请选择单',
      trigger: 'change'
    }]
  }
  ,{
    label: '角色',
    prop: 'role',
    formslot: true,
    slot: true,
    overHidden: true,
    hide: true,
    span: 24,
    rules: [{
      required: true,
      message: '请选择角色',
      trigger: 'blur'
    }]
  }, {
    label: '排序',
    prop: 'rySort',
    value: '999',
    span: 12,
    hide: true,
    type: 'number',
    rules: [{
      required: true,
      message: '请填写排序',
      trigger: 'change'
    }]
  },  {
    label: '状态',
    prop: 'lockFlag',
    type: 'select',
    slot: true,
    border: true,
    span: 12,
    rules: [{
      required: true,
      message: '请选择状态',
      trigger: 'blur'
    }],
    dicData: [{
      label: '有效',
      value: '0'
    }, {
      label: '锁定',
      value: '9'
    }]
  }, {
    width: 180,
    label: '创建',
    prop: 'createTime',
    type: 'datetime',
    format: 'yyyy-MM-dd',
    valueFormat: 'yyyy-MM-dd HH:mm:ss',
    editDisabled: true,
    addDisplay: false,
    span: 24
  }, {
      label: '签名图片',
      prop: 'ryQmtp',
      formslot: true,
      span: 24,
      hide: true
  }, {
      label: '头像',
      prop: 'avatar',
      formslot:true,
      span: 24,
      hide: true,
  },
  // {
  //   label: '员工状态',
  //   prop: 'userStatus',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '员工状态文本',
  //   prop: 'userStatusText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '开始日期',
  //   prop: 'beginDate',
  //   formslot: true,
  //   slot: true,
  //   type: 'datetime',
  //   format: 'yyyy-MM-dd',
  //   valueFormat: 'yyyy-MM-dd HH:mm:ss',
  // },
  // {
  //   label: '结束日期',
  //   prop: 'endDate',
  //   formslot: true,
  //   slot: true,
  //   type: 'datetime',
  //   format: 'yyyy-MM-dd',
  //   valueFormat: 'yyyy-MM-dd HH:mm:ss',
  // },
  // {
  //   label: '首次参加工日日期',
  //   prop: 'dateFirstJob',
  //   formslot: true,
  //   slot: true,
  //   type: 'datetime',
  //   format: 'yyyy-MM-dd',
  //   valueFormat: 'yyyy-MM-dd HH:mm:ss',
  // },
  // {
  //   label: '婚姻状况',
  //   prop: 'maritalStatus',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '职位名称简称',
  //   prop: 'stationSText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '公司代码',
  //   prop: 'companyCode',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '公司代码文本',
  //   prop: 'companyCodeText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '员工组',
  //   prop: 'userGroup',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '员工组名称',
  //   prop: 'userGroupText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '员工子组',
  //   prop: 'userSubGroup',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '员工子组文本',
  //   prop: 'userSubGroupText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '技能级别',
  //   prop: 'skillLevel',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '技能级别文本',
  //   prop: 'skillLevelText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '专业资格名称',
  //   prop: 'qualificationName',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '专业资格名称文本',
  //   prop: 'qualificationNameText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '专业资格级别',
  //   prop: 'qualificationLevel',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '专业资格级别文本',
  //   prop: 'qualificationLevelText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '人事范围',
  //   prop: 'personnelArea',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '人事范围全称',
  //   prop: 'personnelAreaLText',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '人事子范围',
  //   prop: 'personnelSubArea',
  //   formslot: true,
  //   slot: true,
  // },
  // {
  //   label: '人事子范围全称',
  //   prop: 'personnelSubAreaLText',
  //   formslot: true,
  //   slot: true,
  // }
  ]
}
